I have a dialog containing a text entry field with a calendar icon that when clicked displays a calendar lookup. Next to that is a button that calls a function to copy the text entry field values to a list of other fields in the dialog. The code is below. If I simply enter a date and hit the Copy button, it works fine. But if I click the calendar icon to select a date from the calendar lookup, the FIRST time I click 'Copy', I get this error:
"Uncaught TypeError: Cannot read properties of null (reading 'opener')"
The SECOND time I click 'Copy', it copies the date to the other fields. Something about clicking the calendar icon first is screwing up opener(). I am not a JS expert so if you have any suggestions, please be explicit with instructions on how to fix it. Thanks in advance for any help!
// DATE TEXT ENTRY FIELD
html += "<tr><td colspan='4'></td><td><input size='18' type='text' id='uphs_samedate'></td>";
// CALENDAR LOOKUP ICON
html += "<td><a style='display:inline;' displaystyle='inline' id='uphs_samedate_img' href='#' title='/Look up a date' onclick=\"sapphire.lookup.date.open('uphs_samedate','','','','MM/dd/yy hh:mm:ss a','S M' );return false;\" tabindex='0'><img title='Lookup a date' border='0' src='WEB-CORE/imageref/flat/16/flat_black_calendar2.svg'></a></td>";
// BUTTON TO COPY DATE FROM TEXT ENTRY FIELD TO OTHER TEXT FIELDS BELOW
html += "<td><button type='button' id='uphs_setdatebutton' onclick='sapphire.ui.dialog.getDialogObject().opener.uphs_colxn_set_copydownvalues("+ dsLength +")'>Copy Down</button></td></tr>";
... [LIST OF TEXT FIELDS TO WHICH TO COPY ABOVE DATE]